package com.example.day2.busi.my;

import androidx.lifecycle.MutableLiveData;

import com.example.day2.entity.IconResult;
import com.example.day2.entity.UpDateAddress;
import com.example.day2.entity.UpDateBrith;
import com.example.day2.entity.UpDateSexResult;
import com.example.day2.entity.VideoResult;
import com.example.day2.mvvm.base.BaseViewModel;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okio.Utf8;
import retrofit2.http.Multipart;


public class MyViewModel extends BaseViewModel<MyRepo> {
    protected MutableLiveData<VideoResult> success = new MutableLiveData<>();
    protected MutableLiveData<String> fail = new MutableLiveData<>();
    public void getLives(){
        repo.getLives(success,fail);
    }


    protected MutableLiveData<UpDateSexResult> successSex = new MutableLiveData<>();
    protected MutableLiveData<String> failSex = new MutableLiveData<>();
    public void getSex(String sex){
        repo.getSex(sex,successSex,failSex);
    }


    protected MutableLiveData<IconResult> successIcon = new MutableLiveData<>();
    protected MutableLiveData<String> failIcon = new MutableLiveData<>();
    public void getIcon(String part){
        File file = new File(part);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=UTF-8 "), file);
        MultipartBody.Part part1 = MultipartBody.Part.createFormData("file", file.getName(), requestBody);

        repo.getIcon(part1,successIcon,failIcon);
    }


    protected MutableLiveData<UpDateBrith> successBrith = new MutableLiveData<>();
    protected MutableLiveData<String> failBrith = new MutableLiveData<>();
    public void getBrith(String part){
       repo.getBrith(part,successBrith,failBrith);
    }


    protected MutableLiveData<UpDateAddress> successAddress = new MutableLiveData<>();
    protected MutableLiveData<String> failAddress = new MutableLiveData<>();
    public void getAddress(String part){
        repo.getAddress(part,successAddress,failAddress);
    }
    @Override
    public MyRepo createRepo() {
        return new MyRepo();
    }
}
